// 根据 process.env.HOST 的值判断当前是什么环境
// 命令：npm run build -- test ，process.env.HOST就设置为：'test'
let HOST = import.meta.env.DEV ? "fat" : "prod";
// HOST = 'prod'//正式环境
let SERVER_IP: any = {};
let agreements = { http: "http", ws: "ws" }; // 协议

// 如果浏览器使用的是https协议，则所有链接都改成相应协议
if (window.location.href.startsWith("https:")) {
  agreements = { http: "https", ws: "wss" };
}

SERVER_IP[HOST] = `${agreements.http}://${window.location.host}`;
let WS_HOME: any = {};
WS_HOME[HOST] = `${agreements.ws}://${window.location.host}`;

let WEB_HOME = import.meta.env.DEV
  ? `${agreements.http}://localhost:5173/`
  : `/static/module1`;

// ---------------本地调试时打开下方注释--------------
// SERVER_IP = {
//   fat: `${agreements.http}://172.20.62.103`,
//   test: `${agreements.http}://192.168.5.43`,
//   temp: `${agreements.http}://172.20.62.180`, //临时版
//   prod: `${agreements.http}://172.20.62.235`, //搬迁地址
// };
// WS_HOME = {
//   fat: `${agreements.ws}://172.20.62.103`,
//   test: `${agreements.ws}://192.168.5.43`,
//   temp: `${agreements.ws}://172.20.62.184`, //临时版
//   prod: `${agreements.ws}://172.20.62.235`, //搬迁地址
// };
// -------若使用正式环境数据，还需打开下方注释---------

const IP_URL = SERVER_IP[HOST];
const HOME = `${IP_URL}/shrise/shrise`;
const SHIOR_HOME = `${IP_URL}/shior/shior`;
const BIG_SCREEN_HOME = `${IP_URL}/bigscreen/bigscreen`;
const SHMETRO_HOME = `${IP_URL}/shmetro/shmetro`;
const WEBSOCKET_URL = `${WS_HOME[HOST]}/websocket/webclient`;
const MESSAGE = `${IP_URL}/message/message`;

// 基础数据服务器地址

const BASE_HOME = `${IP_URL}/main`;

// 云服务地址
const CLOUD_HOME = `${IP_URL}/auth`;

// 登陆地址的url
const LOGIN_URL = `${CLOUD_HOME}/login.html?redirectUri=${WEB_HOME}`;

// 登出地址的url
// const LOGOUT_URL = `${CLOUD_HOME}/authentication/logout?redirectUri=${WEB_HOME}`;

// 后台服务对应的vesion
const VERSION = HOST;

const WEATHER_ICON = {
  暴雨: "10",
  大暴雨: "11",
  特大暴雨: "12",
  阵雪: "13",
  小雪: "14",
  中雪: "15",
  大雪: "16",
  暴雪: "17",
  雾: "18",
  冻雨: "19",
  沙尘暴: "20",
  小到中雨: "21",
  中到大雨: "22",
  大到暴雨: "23",
  暴雨到大暴雨: "24",
  大暴雨到特大暴雨: "25",
  小到中雪: "26",
  中到大雪: "27",
  大到暴雪: "28",
  浮尘: "29",
  扬沙: "30",
  强沙尘暴: "31",
  霾: "53",
  "": "99",
  晴: "0",
  多云: "01",
  阴: "02",
  阵雨: "03",
  雷阵雨: "04",
  雷阵雨伴有冰雹: "05",
  雨夹雪: "06",
  小雨: "07",
  中雨: "08",
  大雨: "09",
};
const LINE_COLOR = {
  1: "#EA0437",
  2: "#0F9D46",
  3: "#FFD100",
  4: "#4F1F91",
  5: "#A24CC8",
  6: "#520128",
  7: "#FF7200",
  8: "#004052",
  9: "#78C7EB",
  10: "#BCA8DF",
  11: "#7C2230",
  12: "#007B63",
  13: "#F293D1",
  16: "#32D4CB",
  17: "#C59B82",
};
// 地图过滤选项
const FILTER_OPTION = {
  fault3: { type: "fault", name: "严重故障", level: 3 },
  fault2: { type: "fault", name: "一般故障", level: 2 },
  fault1: { type: "fault", name: "轻微故障", level: 1 },
  alert3: { type: "alert", name: "严重预警", level: 3 },
  alert2: { type: "alert", name: "一般预警", level: 2 },
  alert1: { type: "alert", name: "轻微预警", level: 1 },
};

let blue =
  "";
let blueGreen =
  "";
let yellow =
  "";
let blueImg = new Image();
blueImg.src = blue;
let blueGreenImg = new Image();
blueGreenImg.src = blueGreen;
let yellowImg = new Image();
yellowImg.src = yellow;
const ECHART_IMG_BASE64 = { blue, blueGreen, yellow };

// echart纹理柱
const ECHART_IMG_MAP = {
  1: { colorType: "img", color: { image: blueGreenImg, repeat: "repeat" } },
  2: { colorType: "img", color: { image: yellowImg, repeat: "repeat" } },
  3: { colorType: "img", color: { image: blueImg, repeat: "repeat" } },
};

export default {
  BASE_HOME,
  VERSION,
  IP_URL,
  WS_IP: WS_HOME[HOST],
  HOME,
  SHIOR_HOME,
  WEATHER_ICON,
  BIG_SCREEN_HOME,
  SHMETRO_HOME,
  WEBSOCKET_URL,
  LINE_COLOR,
  FILTER_OPTION,
  ECHART_IMG_MAP,
  ECHART_IMG_BASE64,
  WEB_HOME,
  MESSAGE,
  HOST,
  LOGIN_URL,
};
